import 'dart:math';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:get/get.dart';
import 'package:get/get_core/src/get_main.dart';
import 'package:get/get_state_manager/get_state_manager.dart';
import 'package:jydoctorflutter/pages/login/LoginVC.dart';
import 'package:jydoctorflutter/utils/tools/log_util.dart';
import 'package:logger/logger.dart';

import '../../generated/assets.dart';
import '../../routes/routes.dart';

class LoginView extends StatelessWidget {
  const LoginView({super.key});


  @override
  Widget build(BuildContext context) {
    final logic = Get.put(LoginVC());
    return Scaffold(
      appBar: AppBar(
        backgroundColor:Colors.white,
        elevation: 0,
        leading: IconButton(
          icon: Image.asset(
            "assets/icon/common_back.png",
            width: 62,
            height: 24,
          ),
          onPressed: () {
            // 点击关闭按钮时，清空栈里所有中间页面直到返回指定页面
            // Get.offAndToNamed(Routes.iniatial);
            // Future.delayed(const Duration(milliseconds: 100), () {
            //   final logic = Get.put(MainTabbarLogic());
            //   logic.jumpPage(0);
            // });
          },
        ),
      ),
      body:  // TODO: implement build
       Material(
        child:GestureDetector(
          onTap: (){
            print("221");//关闭键盘
            FocusScope.of(context).requestFocus(FocusNode());
          },
          child:  Container(
            child: Column(
              children: [
                Container(
                  child: Container(
                    child: Image.asset('assets/icon/icon.png'),
                    margin: EdgeInsets.only(top: 60, bottom: 0),
                    width: 76, height: 76,
                  ),
                ),
                Container(
                    height: 28,
                    margin: EdgeInsets.only(top: 12, bottom: 36),
                    child: RichText(
                        text: TextSpan(text: '精准防艾', style: TextStyle(
                            color: Colors.black,
                            fontSize: 20,
                            fontWeight: FontWeight.w600)))
                ),
                Container(
                  height: 50,
                  margin: EdgeInsets.only(left: 32, right: 32),
                  decoration: BoxDecoration(
                      borderRadius: BorderRadius.all(Radius.circular(25)),
                      border: Border.all(color: Color(0xFFD43D3F))
                  ),
                  child: Row(
                    crossAxisAlignment: CrossAxisAlignment.center,
                    children: [
                      Container(
                        margin: EdgeInsets.only(left: 17),
                        width: 30, height: 30,
                        child: Image.asset('assets/icon/iphone.png'),
                      ),
                      Expanded(
                          child: Container(
                            // alignment: Alignment.center,
                            margin: EdgeInsets.only(
                                left: 8, right: 17, top: 0, bottom: 0),
                            child: TextField(
                              inputFormatters: [
                                LengthLimitingTextInputFormatter(11),
                              ],
                              keyboardType: TextInputType.number,
                              textAlign: TextAlign.start,
                              decoration: InputDecoration(
                                hintText: '请输入您的手机号',
                                hintStyle: TextStyle(
                                    color: Colors.black, fontSize: 14),
                                border: InputBorder.none, // 移除默认边框
                                // fillColor: Colors.yellow,
                                // filled: true,
                                // hintText: 'Hint text',
                              ),
                              onChanged: (text) {
                                // 处理文本变化事件
                                logE('12333344'+ text );
                                logic.telephoneNUm = text ;
                              },
                              onSubmitted: (text) {

                                logE('1233334455'+ text);
                              },

                            ),
                          )

                      ),

                    ],
                  ),
                ),
                InkWell(
                  child: Container(
                      height: 50,
                      margin: EdgeInsets.only(left: 32, right: 32, top: 44),
                      decoration: BoxDecoration(color: Color(0xFFD43D3F),
                          borderRadius: BorderRadius.circular(25)),
                      child: Center(
                        child: Text('下一步',
                          style: TextStyle(fontSize: 16, color: Colors.white),),
                      )
                  ),
                  onTap: () {

                    logic.gotoSendCode();
                  },
                ),
                Expanded(child: Container()),
                Obx(() {
                  return Container(
                    // height: 17,

                    margin: EdgeInsets.only(left: 32, right: 32, bottom: 50),
                    // child: SizedBox.expand(
                        child: Container(
                          child: Row(
                           mainAxisAlignment: MainAxisAlignment.center ,
                            children: [
                              InkWell(
                                child: Container(
                                  width: 17,
                                  height: 17,
                                  margin: EdgeInsets.only(right: 8),
                                  child: Image.asset(logic.isselect.value
                                      ? Assets.imagesIcRadioB
                                      : Assets.imagesIcRadioA),
                                ),
                                onTap: () {
                                  // controller.continueWithApple();
                                  logic.clickPra();
                                },
                              ),
                              RichText(text: TextSpan(text: '同意与阅读',style: sepicTextStyle.praText)),
                              RichText(text: TextSpan(text: '《隐私政策》',style: sepicTextStyle.praRedText)),
                              RichText(text: TextSpan(text: '和',style: sepicTextStyle.praText)),
                              InkWell(
                                child: RichText(text: TextSpan(text: '《用户服务协议》',style: sepicTextStyle.praRedText)),
                                onTap: (){
                                  Get.toNamed(Routes.webPrivacy,arguments: "http://119.29.142.236:8082/static/dist/index.html#/policy");
                                },
                              )
                            ],
                          ),
                        ),

                    // ),
                  );
                }),
              ],
            ),
            color: Colors.white,
          ),
        )
      )
    );
  }
}
class sepicTextStyle {

  static const praText  = TextStyle(
    fontSize: 12,
    color: Colors.black,
  );

  static const praRedText  = TextStyle(
    fontSize: 12,
    color: Color(0xFFD43D3F),
  );
}